package com.zhongyu.controller;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.zhongyu.pojo.Echarts;
import com.zhongyu.pojo.GoodsType;
import com.zhongyu.pojo.OrderDetail;
import com.zhongyu.pojo.Xsreport;
import com.zhongyu.service.XSreportService;
import com.zhongyu.vo.ResultVo;
import com.zhongyu.vo.XsReportVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/cus/xstjb")
public class XSreportController {
    @Resource
    private XSreportService xSreportService;
    @GetMapping("/list")
    public ResultVo orderReport(XsReportVo xsReportVo){
        List<Xsreport> reportData =xSreportService.orderReport(xsReportVo.getStartDate(), xsReportVo.getEndDate());
        return  ResultVo.success(reportData);
    }
    @GetMapping("/list1")
    public ResultVo orderReport1(){
        List reportData = xSreportService.search();
        return  ResultVo.success(reportData);
    }

    @GetMapping("/EcharsShow")
    public List<Echarts> orderReport2(XsReportVo xsReportVo){
  //      List <Xsreport> reportData = xSreportService.search();
        System.out.println(xsReportVo.getStartDate());
        List<Xsreport> reportData1 =xSreportService.orderReport(xsReportVo.getStartDate(), xsReportVo.getEndDate());

        List<Echarts> list = new ArrayList<Echarts>();
      for (Xsreport xsreport:reportData1){
          String name=xsreport.getGoodsTpname();
          Double value=xsreport.getMoney();
          list.add(new Echarts(name,value));
      }
        return  list;
    }


}
